package realdance.swing;

import java.awt.BorderLayout;
import java.awt.EventQueue;
import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.UIManager;
import javax.swing.border.EmptyBorder;

import ch.randelshofer.quaqua.QuaquaManager;

public class SwingMain extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					
			
					// quaqua 룩앤필 적용(1)
					//System.setProperty(
					//		"Quaqua.tablayoutPolicy", "wrap");
					EventQueue.invokeLater(new Runnable() {
						
						@Override
						public void run() {
							try {
								//quaqua 룩앤필 적용
								//UIManager.setLookAndFeel(QuaquaManager.getLookAndFeel());
								Thread.sleep(2000);
							} catch (Exception e) {
								e.printStackTrace();
							}
							SwingMain frame = new SwingMain();
							frame.setLocationRelativeTo(null);
					// 화면 정중앙에 표시
							frame.setIconImage(initIcon());
					//JFrame에 사용할 아이콘 지정
							frame.setVisible(true);
							
						}
					
					});					
					
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public SwingMain() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setTitle(":: 스윙 세미 프로젝트 ::"); // 제목 지정
		setBounds(100, 100, 1024, 768);
		setResizable(false); //크기변경불가
		
		setJMenuBar(new SwingMenu());
		// JFrame에 메뉴바 추가	
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		contentPane.setLayout(new BorderLayout(0, 0));
		
		new SwingPopupMenu(contentPane); 
		// 팝업메뉴 추가
		
		
		contentPane.add(new SwingToolBar(),
				BorderLayout.NORTH); // 툴바 추가
		contentPane.add(new SwingStatusBar(),
				BorderLayout.SOUTH);
		setContentPane(contentPane);
	}
	
	
	// 프로그램 아이콘 불러오기
	private static Image initIcon(){
		String image = "/images/main/cat.png";
		Image icon = new ImageIcon(
				SwingMain.class.getResource(image))
		.getImage();
		return icon;
		
	}
}
